Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Support :var Input to org babel code blocks #4

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

rosenstrauch
Copy link

@rosenstrauch rosenstrauch commented Nov 21, 2024

for testing i used the following blocks

#+NAME: ob-dart-variables-result-output
#+BEGIN_SRC dart :var projectname="dart" :var input="why" :results output
print("Project Name: $projectname");
print("Input: $input");
#+END_SRC

#+NAME: ob-dart-variables-result-value
#+BEGIN_SRC dart :var projectname="dart" :var input="why" :results value
return "Project Name: $projectname, Input: $input";
#+END_SRC

#+NAME: dart-body-main
#+begin_src dart :results output
/// Complete Dart code snippet can be wrapped.
main(List args) {
var listMax = [10,20,30].reduce(max);
print ('WE HAVE MAIN');
print ('In output mode, all printed lines show in result');
print ('List max printed = ' + listMax.toString());
return ('Results: value!! List from MAIN');
}
main([]);
#+end_src

#+RESULTS: dart-body-main
: WE HAVE MAIN
: In output mode, all printed lines show in result
: List max printed = 30

#+NAME: ob-dart-function
#+begin_src dart :var number=4
square(x) {
return x * x;
}
return square(number);
#+end_src

#+RESULTS: ob-dart-function
: 16

#+NAME: ob-dart-print-var-input
#+begin_src dart :var input="why" :results output
// Access the variable using the vars object
var message = "$input";

// Use the input variable
print(message);
#+end_src

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant